unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses
  PerlRegEx;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  Perl:TPerlRegEx;
begin
  Perl := TPerlRegEx.Create(nil);
  try
    Perl.Subject:='[5]=[1]+[2]-[7]-[1]+[8]-[1223]';
    Perl.RegEx:='\[\d+\]=\[\d+\]((\-|\+)\[\d+\])+';   //


    {Perl.Subject:='[5]=[1]-[2]-[7]-[6]+[123]-[123]';
    Perl.RegEx:='\[\d+\]=\[\d+\](\-|\+\[\d+\])';}
    {Perl.Subject := 'abc A1111 BB222 CCC33 DDDD4';
    Perl.RegEx   := '\b([A-D]+)([1-4]+)\b';  }

    {if Perl.Match then
    begin
      ShowMessage('It is Match');
    end else
    begin
      ShowMessage('No Match');
    end; }

    while Perl.MatchAgain do
    begin
      ShowMessage(Perl.MatchedExpression);
    end;  
  finally
    Perl.Free;
  end;

end;

end.
